package com.myFwk.controller;

import com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiDefinition;
import com.alibaba.csp.sentinel.adapter.gateway.common.api.GatewayApiDefinitionManager;
import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayFlowRule;
import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayRuleManager;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Set;

/**
 * @Title:
 * @Description:
 * @Author: guowl
 * @version： 1.0
 * @Date:2021/8/25
 * @Copyright: Copyright(c)2021 RedaFlight.com All Rights Reserved
 */
@RestController
public class GateWayFlowRuleController {
    /**
     * 获取当前系统的限流
     * @return
     */
    @GetMapping("/gw/flow/rules")
    public Set<GatewayFlowRule> getCurrentGateWayFlowRules() {
        return GatewayRuleManager.getRules();
    }

    /**
     * 获取自定义的api分组
     * @return
     */
    @GetMapping("/gw/api/groups")
    public Set<ApiDefinition> getApiGroups() {
        return GatewayApiDefinitionManager.getApiDefinitions();
    }


}
